package com.weaver.qfengx.entity;

/**
 * @Description
 * @Author Qfengx <qffg1998@126.com>
 * @Date 2021-07-20 20:43:46
 */

public class PageQuery {

    private Long page;
    private Long limit;
    private Long startNum;
    private Long endNum;

    public PageQuery(Long page, Long limit) {
        this.page = page;
        this.limit = limit;
        init();
    }

    public PageQuery(Integer page, Integer limit) {
        this.page = Long.parseLong(Integer.toString(page));
        this.limit = Long.parseLong(Integer.toString(limit));
        init();
    }

    private void init() {
        if (this.page == null || this.page < 1) {
            this.page = 1L;
        }
        if (this.limit == null || this.limit < 1) {
            this.limit = 10L;
        }
        this.startNum = (this.page - 1) * this.limit;
        this.endNum = this.startNum + this.limit;
    }

    public Long getPage() {
        return page;
    }

    public Long getLimit() {
        return limit;
    }

    public Long getStartNum() {
        return startNum;
    }

    public Long getEndNum() {
        return endNum;
    }
}
